package com.banciyuan.bcywebview.base.factory;

import com.banciyuan.bcywebview.biz.detail.comment.CommentHelper;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import org.json.JSONArray;

import java.util.List;

import de.greenrobot.daoexample.model.ForumThread;

/**
 * Created by hfxt2008 on 14-8-22.
 * 生成ForumThread类的工厂类，用于解析json，然后生成一个list<ForumThread>
 */
public class ForumThreadFactory {

    public static List<ForumThread> createForumThread(JSONArray json) {
        Gson gson = new Gson();

        List<ForumThread> flist = gson.fromJson(json.toString(), new TypeToken<List<ForumThread>>() {
        }.getType());
        for (int i = 0; i < flist.size(); i++) {
            CommentHelper.processTalkList(flist.get(i).getReply_data());
        }
        return flist;
    }
}
